<?php
/*
  Capitalize names, surnames etc... formatting the fields of the customer

  By fightsol.com fightsol@gmail.com

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com
  Released under the GNU General Public License

*/

Sorry if my english is not too good, i thought it will be better for more people to have this in english even when is not my mother language.

For aesthetic reasons mainly, most of people like to have the names and addresses in a capitalized form.
The problem is that we can't control what the customer adds when is making a new account or editing an existing one.

The solution is easy, get the strings just before updating the database to use the php functions to put the words in the way we want.
  
There is 4 files to edit, all placed in /catalog (or your root directory)
checkout_shipping_address.php
address_book_process.php
account_edit.php
create_account.php

You must search for the fields you use, normally:
$firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']);
$lastname = tep_db_prepare_input($HTTP_POST_VARS['lastname']);
$street_address = tep_db_prepare_input($HTTP_POST_VARS['street_address']);	
$email_address = tep_db_prepare_input($HTTP_POST_VARS['email_address']);

Maybe you can need to format also other fields like $city, this has no dificulty because all of them are clearly visible close to the previous fields above.

What you need to do is to re-asign every variable for the field ($firstname...) with the formatted by php string.
Normally you can do it like this:

Find:
$firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']);

Replace with:
$firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']);
$firstname = mb_convert_encoding(mb_convert_case($firstname, MB_CASE_TITLE), "UTF-8"); 

If you have problems with any strange chars like ,  etc... you must check what codification is using your website and database.
To avoid problems i need to add this function after the mb_convert_encoding:
$firstname = utf8_decode($firstname);
So if this is your scenario, the full code will be

$firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']);
$firstname = mb_convert_encoding(mb_convert_case($firstname, MB_CASE_TITLE), "UTF-8"); 
$firstname = utf8_decode($firstname);

The same we have done with $firstname must be done with the other fields ($lastname...) in the case of $email_address is more aesthetic to put all the chars in lower case so in this case the code will be

FIND:
$email_address = tep_db_prepare_input($HTTP_POST_VARS['email_address']);

REPLACE WITH:
$email_address = tep_db_prepare_input($HTTP_POST_VARS['email_address']);
$email_address = strtolower($email_address);
(OPTIONAL LINE TO ADD IF YOU HAVE UTF PROBLEMS!) $email_address = utf8_decode($email_address);



Also, if you have a running shop, you can modify the database with the UPDATE function to convert all the customers previously registered.
IMPORTANT!!: You are gonna modify the database so do a full backup of the database before doing this, because in case of problems you can have serious trouble if you're doing it in a real shop.
Here you have an example of how to change a full field in the database; make a new php file, connect to the database and then use this:

$convertir = mysql_query("select * from customers");
if ($row = mysql_fetch_array($convertir))
{ 
 	do 
  	{ 
		$str = $row["customers_firstname"];
		$str = mb_convert_encoding(mb_convert_case($str, MB_CASE_TITLE), "UTF-8"); 
		(THIS LINE IS OPTIONAL) $str = utf8_decode($str);
 		$sql = "UPDATE orders SET customers_firstname = '" . $str . "' WHERE customers_id = '" . $row["customers_id"] . "'";
		mysql_query ( $sql , $link ); // CHANGE $link WITH THE NAME OF YOUR PREVIOUS ASSIGNED MYSQL CONNECTION VARIABLE
     }
  	while ($row = mysql_fetch_array($convertir)); 
}

With this all the registered users in your website will have a capitalized First Name.
Do the same with the other fields to finish the work.

Hope this will help someone! Feel free to email me to the email address at the top of the file if you want!